import {Provide} from "@midwayjs/decorator";
import {InjectEntityModel} from "@midwayjs/orm";
import {Repository} from "typeorm";
import {Resource} from "../entity/resource";


@Provide()
export class ResourceService {
  @InjectEntityModel(Resource)
  resourceModel: Repository<Resource>;
  async getList(){
    let resourceList = await this.resourceModel.find()
    return resourceList;
  }

  async save(data) {
    let rs:any='';
    rs=await this.resourceModel.save(data);

    if(rs && Object.keys(rs).length>0){
      return {
        success: true,
        msg:'保存成功'
      }
    }else{
      return {
        success: false,
        msg:'保存失败'
      }
    }
  }
}
